<template>
  <div>
    <Breadcrumb>
      <BreadcrumbItem>借贷人员信息管理</BreadcrumbItem>
    </Breadcrumb>
    <Divider />
    <!-- 模糊查询 -->
    <Form ref="formInline" label-position="left" :label-width="0" :model="formInline" inline>
      <FormItem label prop="exName">
        <i-input :value.sync="value" placeholder="请输入..." style="width: 250px"></i-input>
      </FormItem>
      <Button type="primary" @click="selectSubmit('formInline')">查询</Button>
    </Form>
    <!--删除 -->
    <!-- <div class="del">
      <Button type="primary" icon="md-add" @click="propertyAdd">添加</Button>
      <Button type="error" label-position="right" class="sc">批量删除</Button>
    </div> -->
    <Table border :columns="columns7" :data="data6" class="table"></Table>

    <Page :total="pageTotal" 
    :current="pageNum" 
    :page-size="pageSize" 
    show-elevator 
    show-sizer 
    show-total 
    placement="top"  
    @on-change="handlePage" 
    @on-page-size-change='handlePageSize'
    class="ye">
    </Page>

    <!-- 修改密码弹窗
    <Modal v-model="formTable.modal" title="用户修改" @on-cancel="modalCancel">
      <Form
        ref="formTable"
        label-position="right"
        :rules="formTableRules"
        :label-width="90"
        :model="formTable"
      >
        <Form-item label="姓名" prop="userName">
          <i-input v-model="formTable.userName" placeholder="请输入姓名"></i-input>
        </Form-item>
        <Form-item label="性别" prop="gender">
          <i-input v-model="formTable.gender" placeholder="请输入性别"></i-input>
        </Form-item>
        <Form-item label="身份证号" prop="autitedIdcode">
          <i-input v-model="formTable.autitedIdcode" placeholder="请输身份证号"></i-input>
        </Form-item>
        <Form-item label="贷款金额" prop="debitAmount">
          <i-input v-model="formTable.debitAmount" placeholder="请输入贷款金额"></i-input>
        </Form-item>
        <Form-item label="贷款期限" prop="debitLimit">
          <i-input v-model="formTable.debitLimit" placeholder="请输入贷款期限"></i-input>
        </Form-item>
        <Form-item label="利率" prop="rates">
          <i-input v-model="formTable.rates" placeholder="请输入利率"></i-input>
        </Form-item>
        <Form-item label="剩余还款总额" prop="surplusAmount">
          <i-input v-model="formTable.surplusAmount" placeholder="请输入剩余还款总额"></i-input>
        </Form-item>
        <Form-item label="借款日期" prop="debitDate">
          <i-input v-model="formTable.debitDate" placeholder="请输入借款日期"></i-input>
        </Form-item>
        <Form-item label="剩余期数" prop="surplusNumber">
          <i-input v-model="formTable.surplusNumber" placeholder="请输入剩余期数"></i-input>
        </Form-item>
      </Form>
      <div slot="footer">
        <Button @click="modalCancel">取消</Button>
        <Button type="primary" icon="checkmark" :loading="formTable.loading" @click="editSubmit">修改</Button>
      </div>
    </Modal> -->
  </div>
</template>
<script>
export default {
  data() {
    const validatePassCheck = (rule, value, callback) => {};
    return {
      pageTotal: 0, //数据总数
      pageNum: 1, //初始页
      pageSize: 10, //每页条数
      formInline: {
        userName: ""
      },
      formTable: {
        userId:"",
        ratesId:"",
        modal: false,
        loading: false,
        debitOrderId: "",
        userName: "",
        gender: "",
        autitedIdcode: "",
        debitAmount: "",
        debitLimit: "",
        rates: "",
        surplusAmount: "",
        debitDate: "",
        surplusNumber: ""
      },
      columns7: [
        {
          type: "selection",
          width: 80,
          align: "center"
        },
        {
          title: "编号",
          key: "debitOrderId",
          width: 90,
          align: "center"
          // render: (h, params) => {
          //   return h('div', [
          //     h('Icon', {
          //       props: {
          //         type: 'role'
          //       }
          //     }),
          //     h('strong', params.row.debitOrderId)
          //   ])
          // }
        },
        {
          title: "姓名",
          key: "userName",

          align: "center"
        },
        {
          title: "性别",
          key: "gender",
          align: "center",
          width: 70
        },
        {
          title: "身份证号",
          key: "autitedIdcode",
          align: "center"
        },
        {
          title: "贷款金额",
          key: "debitAmount",
          align: "center"
        },
        {
          title: "借贷期限",
          key: "debitLimit",
          align: "center"
        },
        {
          title: "利率",
          key: "rates",
          align: "center"
        },
        {
          title: "剩余还款总额",
          key: "surplusAmount",
          align: "center"
        },
        {
          title: "借款日期",
          key: "debitDate",
          align: "center"
        },
        {
          title: "剩余期数",
          key: "surplusNumber",
          align: "center",
          width: 90
        },
        // {
        //   title: "操作",
        //   key: "action",
        //   align: "center",
        //   render: (h, params) => {
        //     return h("div", [
        //       h(
        //         "Button",
        //         {
        //           props: {
        //             type: "primary",
        //             size: "small"
        //           },
        //           style: {
        //             marginRight: "10px"
        //           },
        //           on: {
        //             click: () => {
        //               this.orderEdit(params.row);
        //             }
        //           }
        //         },
        //         "修改"
        //       ),
        //       h(
        //         "Button",
        //         {
        //           props: {
        //             type: "error",
        //             size: "small"
        //           },
        //           on: {
        //             click: () => {
        //               this.remove(params.index, params.row);
        //             }
        //           }
        //         },
        //         "删除"
        //       )
        //     ]);
        //   }
        // }
      ],
      data6: [
        {
          userId:"",
          ratesId:"",
          debitOrderId: "",
          userName: "",
          gender: "",
          autitedIdcode: "",
          debitAmount: "",
          debitLimit: "",
          rates: "",
          surplusAmount: "",
          debitDate: "",
          surplusNumber: ""
        }
      ]
    };
  },
  methods: {
     //分页
    handlePage(value) {
      console.log(value);
      this.pageNum = value;
      this.getDebitOrder();
    },

    handlePageSize(value) {
      console.log(value);
      this.pageSize = value;
      this.getDebitOrder();
    },

    getDebitOrder(){
        this.$axios.get("debitOrder",{
          params:{
            pageNum:this.pageNum,
            pageSize:this.pageSize
          }
        }).then(response => {
          console.log(response.data)
          this.pageTotal = response.data.tatol
          var result = response.data.data;
          this.data6 = [];
          for(let i = 0;i<result.length;i++){
            this.data6.push({
              debitOrderId: result[i].debitOrderId,
              userName: result[i].tbUsers.userName,
              userId: result[i].tbUsers.userId,
              gender: result[i].tbUsers.gender,
              autitedIdcode:result[i].tbVerify.autitedIdcode,
              debitAmount: result[i].debitAmount,
              debitLimit: result[i].debitLimit,
              rates: result[i].tbRates.rates,
              ratesId: result[i].tbRates.ratesId,
              surplusAmount: result[i].surplusAmount,
              debitDate: result[i].debitDate,
              surplusNumber: result[i].surplusNumber
            })

          }

        }).catch(response => {

        })

    },
    //查询
    selectSubmit(userName) {
      this.$refs[userName].validate(valid => {});
    },
    // //删除
    // remove (index) {
    //   this.$Modal.confirm({
    //       title: '温馨提示',
    //       width: 300,
    //       content: '<p>你确定要删除?删除后不可恢复!</p>',
    //       loading: false,
    //       onOk: () => {

    //         this.data6.splice(index, 1);
    //       }
    //     });
    // },
    //删除
    // remove(index, row) {
    //   this.$Modal.confirm({
    //     title: "温馨提示",
    //     width: 300,
    //     content: "<p>你确定要删除?删除后不可恢复!</p>",
    //     loading: false,
    //     onOk: () => {
    //       this.data6.splice(index, row.debitOrderId);
    //       this.$axios.delete("debitorder", {
    //         params: { debitOrderId: row.debitOrderId }
    //       });
    //     }
    //   });
    // },
    //修改
    // editSubmit: function(data) {
    //   console.log(data)
    //   this.formTable.loading = true;
    //   this.$axios
    //     .put("debitorder", {
    //       debitOrderId: this.formTable.debitOrderId,
    //       userName: this.formTable.userName,
    //       userId: this.formTable.userId,
    //       gender: this.formTable.gender,
    //       autitedIdcode: this.formTable.autitedIdcode,
    //       debitAmount: this.formTable.debitAmount,
    //       debitLimit: this.formTable.debitLimit,
    //       rates: this.formTable.rates,
    //       ratesId: this.formTable.ratesId,
    //       surplusAmount: this.formTable.surplusAmount,
    //       debitDate: this.formTable.debitDate,
    //       surplusNumber: this.formTable.surplusNumber
    //     })
    //     .then(response => {
    //       this.formTable.loading = false;
    //       if (response.data.code == 0) {
    //         this.$Notice.success({
    //           title: "信息修改成功"
    //         });
    //       } else {
    //         this.$Notice.error({
    //           title: "信息修改失败"
    //         });
    //       }
    //       this.modalCancel();
    //     })
    //     .catch(console.log(response.data));
    // },
    // 获取每一行值
    // orderEdit(row) {
    //   console.log(row);
    //   this.formTable.modal = true;
    //   this.formTable.debitOrderId = row.debitOrderId;
    //   this.formTable.userName = row.userName;
    //   this.formTable.userId = row.userId;
    //   this.formTable.gender = row.gender;
    //   this.formTable.autitedIdcode = row.autitedIdcode;
    //   this.formTable.debitAmount = row.debitAmount;
    //   this.formTable.debitLimit = row.debitLimit;
    //   this.formTable.rates = row.rates;
    //   this.formTable.ratesId = row.ratesId;
    //   this.formTable.surplusAmount = row.surplusAmount;
    //   this.formTable.debitDate = row.debitDate;
    //   this.formTable.surplusNumber = row.surplusNumber;
    // },
    // // 取消修改
    // modalCancel() {
    //   this.formTable.modal = false;
    //   this.$refs["formTable"].resetFields();
    // }
  },
  //查询所有
  created: function() {
    this.getDebitOrder()
    // this.$axios
    //   .get("debitorders")
    //   .then(response => {
    //     console.log(response.data);
    //     var result = response.data.data;
    //     this.data6=[];
    //     for (let i = 0; i < result.length; i++) {
    //       this.data6.push({
    //         debitOrderId: result[i].debitOrderId,
    //         userName: result[i].tbUsers.userName,
    //         userId: result[i].tbUsers.userId,
    //         gender: result[i].tbUsers.gender,
    //         autitedIdcode:result[i].tbVerify.autitedIdcode,
    //         debitAmount: result[i].debitAmount,
    //         debitLimit: result[i].debitLimit,
    //         rates: result[i].tbRates.rates,
    //         ratesId: result[i].tbRates.ratesId,
    //         surplusAmount: result[i].surplusAmount,
    //         debitDate: result[i].debitDate,
    //         surplusNumber: result[i].surplusNumber
    //       });
    //     }
    //     console.log(this.data6);
    //   })
    //   .catch();
  }
};
</script>
<style>
.ye {
  position: relative;
  margin-top: 30px;
  left: 32%;
}
.table {
  position: relative;
  margin-top: 20px;
}

</style>
